//
//  MainViewController.m
//  MPMoviePlayer
//
//  Created by gavin on 14-2-9.
//  Copyright (c) 2014年 gavin. All rights reserved.
//

#import "MainViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    NSString *path=[[NSBundle mainBundle] pathForResource:@"c" ofType:@"mov"];
    NSURL *url=[[NSURL alloc] initFileURLWithPath:path];
    self.mpMoviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:url];
    self.mpMoviePlayer.view.frame = self.mpViewBG.frame;
    self.mpMoviePlayer.movieSourceType=MPMovieSourceTypeFile;//本地文件播放要设置视频资源为文件类型资源，若设置为stream 则会错误
    [self.mpMoviePlayer prepareToPlay];
    
    if(self.mpMoviePlayer)
    {
        [self.mpMoviePlayer play];
    }
    [self.view addSubview:self.mpMoviePlayer.view];
    
    
    //网络视频
//    self.mpMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http:"]];
//    self.mpMoviePlayer.movieSourceType=MPMovieSourceTypeStreaming;//网络文件要设置为stream
//    [self.mpMoviePlayer play];
//    self.mpMoviePlayer.view.frame= CGRectMake(0, 0, 300, 300);
//    [self.view addSubview:self.mpMoviePlayer.view];

    
}

@end
